﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Bottle.CommunityForum.IBLL
{
    public interface IBaseService<T> where T:class,new ()
    {
        #region 查询

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="wherelambda"></param>
        /// <returns></returns>
         IQueryable<T> QueryEntitys(Expression<Func<T, bool>> wherelambda);

        /// <summary>
        /// 分页查询(order by)
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totle"></param>
        /// <param name="wherelambda"></param>
        /// <param name="ordlambda"></param>
        /// <returns></returns>
         IQueryable<T> QueryPageOrdEntitys<S>(int pageSize, int pageIndex, out int totle, Expression<Func<T, bool>> wherelambda, Expression<Func<T, S>> ordlambda);

        /// <summary>
        /// 分页查询(order by desc)
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totle"></param>
        /// <param name="wherelambda"></param>
        /// <param name="ordlambda"></param>
        /// <returns></returns>
         IQueryable<T> QueryPageDescEntitys<S>(int pageSize, int pageIndex, out int totle, Expression<Func<T, bool>> wherelambda, Expression<Func<T, S>> ordlambda);
        #endregion

        #region 添加

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
         T AddEntity(T entity);
        #endregion

        #region 修改

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
         bool EditEntity(T entity);
        #endregion

        #region 删除

        /// <summary>
         /// 删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
         bool DelEntity(T entity);
        #endregion

         int SaveChanges();
    }
}
